#include "../include/threadPool.h"
#include <sys/sendfile.h>
typedef struct train_s {
    int length;
    char data[1000]; //char数组在此处不是字符串的意思
    // 1000是指长度上限
} train_t;
int transfile(int sockfd){
   train_t train;
   char filename[] = "file1";
   train.length = 5;//火车头
   memcpy(train.data,filename,train.length);
   send(sockfd,&train,sizeof(train.length)+train.length,MSG_NOSIGNAL);//不能写sizeof(train)

   int fd = open(filename,O_RDWR);
   struct stat statbuf;
   fstat(fd,&statbuf);
   printf("filesize = %ld\n", statbuf.st_size);
   off_t filesize = statbuf.st_size;
   train.length = sizeof(filesize);
   memcpy(train.data,&filesize,sizeof(off_t));
   send(sockfd,&train,sizeof(train.length)+train.length,MSG_NOSIGNAL);//不能写sizeof(train)
   sendfile(sockfd,fd,NULL,filesize);
   return 0;
}
